/**
 * Project:   dtu.fmes.googleloon
 * File:      Simulation.java
 * License: 
 *            This file is licensed under GNU General Public License version 3
 *            http://www.gnu.org/licenses/gpl-3.0.txt
 *
 * Copyright: Bartosz Cichecki [ cichecki.bartosz@gmail.com ]
 * Date:      Oct 12, 2013
 */

package dtu.fmes.loon.model;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author Bartosz Cichecki, Nicolai Sonne
 */
public class Simulation {

	private boolean showTargetPosition = false;

	private boolean showOptimailPositions = false;

	private Long currentTime = 0L;

	private Long simulationInterval = null;

	private Long simulationLength = null;

	private Long simulationStart = 0L;

	private List<KillRandomBalloon> killRandomBalloons = new ArrayList<KillRandomBalloon>();

	public Simulation() {

	}

	public Simulation(Long simulationInterval, Long simulationLength) {
		super();
		this.simulationInterval = simulationInterval;
		this.simulationLength = simulationLength;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Simulation other = (Simulation) obj;
		if (currentTime == null) {
			if (other.currentTime != null) {
				return false;
			}
		} else if (!currentTime.equals(other.currentTime)) {
			return false;
		}
		if (killRandomBalloons == null) {
			if (other.killRandomBalloons != null) {
				return false;
			}
		} else if (!killRandomBalloons.equals(other.killRandomBalloons)) {
			return false;
		}
		if (showOptimailPositions != other.showOptimailPositions) {
			return false;
		}
		if (showTargetPosition != other.showTargetPosition) {
			return false;
		}
		if (simulationInterval == null) {
			if (other.simulationInterval != null) {
				return false;
			}
		} else if (!simulationInterval.equals(other.simulationInterval)) {
			return false;
		}
		if (simulationLength == null) {
			if (other.simulationLength != null) {
				return false;
			}
		} else if (!simulationLength.equals(other.simulationLength)) {
			return false;
		}
		if (simulationStart == null) {
			if (other.simulationStart != null) {
				return false;
			}
		} else if (!simulationStart.equals(other.simulationStart)) {
			return false;
		}
		return true;
	}

	public Long getCurrentTime() {
		return currentTime;
	}

	/**
	 * Creates export clone, which only contains values relevant for the output
	 * 
	 * @return
	 */
	public Simulation getExportClone() {
		Simulation exportClone = new Simulation();
		exportClone.setCurrentTime(currentTime);
		return exportClone;
	}

	public List<KillRandomBalloon> getKillRandomBalloons() {
		return killRandomBalloons;
	}

	public Long getSimulationInterval() {
		return simulationInterval;
	}

	public Long getSimulationLength() {
		return simulationLength;
	}

	public Long getSimulationStart() {
		return simulationStart;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (currentTime == null ? 0 : currentTime.hashCode());
		result = prime * result + (killRandomBalloons == null ? 0 : killRandomBalloons.hashCode());
		result = prime * result + (showOptimailPositions ? 1231 : 1237);
		result = prime * result + (showTargetPosition ? 1231 : 1237);
		result = prime * result + (simulationInterval == null ? 0 : simulationInterval.hashCode());
		result = prime * result + (simulationLength == null ? 0 : simulationLength.hashCode());
		result = prime * result + (simulationStart == null ? 0 : simulationStart.hashCode());
		return result;
	}

	public boolean isShowOptimailPositions() {
		return showOptimailPositions;
	}

	public boolean isShowTargetPosition() {
		return showTargetPosition;
	}

	public void setCurrentTime(Long currentTime) {
		this.currentTime = currentTime;
	}

	public void setKillRandomBalloons(List<KillRandomBalloon> killRandomBalloons) {
		this.killRandomBalloons = killRandomBalloons;
	}

	public void setShowOptimailPositions(boolean showOptimailPositions) {
		this.showOptimailPositions = showOptimailPositions;
	}

	public void setShowTargetPosition(boolean showTargetPosition) {
		this.showTargetPosition = showTargetPosition;
	}

	public void setSimulationInterval(Long simulationInterval) {
		this.simulationInterval = simulationInterval;
	}

	public void setSimulationLength(Long simulationLength) {
		this.simulationLength = simulationLength;
	}

	public void setSimulationStart(Long simulationStart) {
		this.simulationStart = simulationStart;
	}

	@Override
	public String toString() {
		return "Simulation [showTargetPosition=" + showTargetPosition + ", showOptimailPositions=" + showOptimailPositions
		        + ", currentTime=" + currentTime + ", simulationInterval=" + simulationInterval + ", simulationLength=" + simulationLength
		        + ", simulationStart=" + simulationStart + ", killRandomBalloons=" + killRandomBalloons + "]";
	}

}
